﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using jmetal.core;

namespace jmetal.experiments.settings
{
  class SettingsFactory
  {
    public Settings getSettingsObject (string algorithmName, Object parameters)
    {
      string str = "jmetal.experiments.settings." + algorithmName + "_settings";

      Type type = Type.GetType (str);
      Type[] types = new Type[1];
      types[0] = typeof(String);

      ConstructorInfo ci = type.GetConstructor (types);
      if (ci != null)
        Console.WriteLine ("Cons: " + ci.ToString ());
      else
        Console.WriteLine ("Cons: error") ;

      var settingsObject = ci.Invoke(new object[] { (String) parameters });

      //Settings settings = type.GetConstructor(null);
      return (Settings)settingsObject ;
    }
  }
}
